//package com.yu8home.yu8home;
//
//import lombok.RequiredArgsConstructor;
//import org.springframework.aop.aspectj.AspectJExpressionPointcut;
//import org.springframework.aop.support.DefaultPointcutAdvisor;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.jdbc.datasource.DataSourceTransactionManager;
//import org.springframework.transaction.annotation.EnableTransactionManagement;
//import org.springframework.transaction.interceptor.TransactionInterceptor;
//
//import javax.sql.DataSource;
//import java.util.Properties;
//
///**
// * 事务AOP
// *
// * @author：yu8home
// * @date：2018年1月11日 上午10:02:03
// */
//@EnableTransactionManagement
//@Configuration
//@RequiredArgsConstructor
//public class TxAdvisor {
//    private final DataSource dataSource;
//
//    @Bean("txManager")
//    public DataSourceTransactionManager txManager() {
//        DataSourceTransactionManager dataSourceTransactionManager = new DataSourceTransactionManager(dataSource);
//        dataSourceTransactionManager.setEnforceReadOnly(true);
//        return dataSourceTransactionManager;
//    }
//
//    @Bean("txAdvice")
//    public TransactionInterceptor txAdvice(DataSourceTransactionManager txManager) {
//        Properties p = new Properties();
//        p.setProperty("get*", "PROPAGATION_SUPPORTS,readOnly");
//        p.setProperty("detail*", "PROPAGATION_SUPPORTS,readOnly");
//        p.setProperty("select*", "PROPAGATION_SUPPORTS,readOnly");
//        p.setProperty("page*", "PROPAGATION_SUPPORTS,readOnly");
//        p.setProperty("list*", "PROPAGATION_SUPPORTS,readOnly");
//        p.setProperty("query*", "PROPAGATION_SUPPORTS,readOnly");
//        p.setProperty("statics*", "PROPAGATION_SUPPORTS,readOnly");
//        p.setProperty("*", "PROPAGATION_REQUIRED,-Exception");
//
//        return new TransactionInterceptor(txManager, p);
//    }
//
//    @Bean
//    public DefaultPointcutAdvisor defaultPointcutAdvisor(TransactionInterceptor txAdvice) {
//        AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
//        pointcut.setExpression("execution(public * com.junli..*ServiceImpl.*(..))");
//
//        return new DefaultPointcutAdvisor(pointcut, txAdvice);
//    }
//
//}
